home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 7
/
Apprentice-Release7.iso
/
Source Code
/
Pascal
/
Applications
/
TCPExample
/
PNL Libraries
/
MyStripTelnetCodes.p
< prev
next >
Wrap
Text File
|
1995-06-04
|
792b
|
51 lines
unit MyStripTelnetCodes;
interface
const
T_WILL = chr(251);
T_WONT = chr(252);
T_DO = chr(253);
T_DONT = chr(254);
T_IAC = chr(255);
procedure StripTelnetCodes (var s: string);
implementation
const
nul = chr(0);
procedure StripTelnetCodes (var s: string);
var
i: integer;
begin
i := 1;
while i < length(s) do begin
case s[i] of
T_IAC: begin
case s[i + 1] of
T_IAC: begin
Delete(s, i, 1);
i := i + 1;
end;
T_WILL, T_WONT, T_DO, T_DONT: begin
if i < length(s) - 1 then begin
Delete(s, i, 3);
end else begin
leave;
end;
end;
otherwise
Delete(s, i, 2);
end;
end;
nul:
Delete(s, i, 1);
otherwise
i := i + 1;
end;
end;
end;
end.